package com.opencee.common.security.oauth2;

import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.code.JdbcAuthorizationCodeServices;

import javax.sql.DataSource;
import java.util.UUID;

/**
 * 自定义认证码生成类
 *
 * @author yadu
 */
public class CustomAuthorizationCodeServices extends JdbcAuthorizationCodeServices {

    public CustomAuthorizationCodeServices(DataSource dataSource) {
        super(dataSource);
    }

    @Override
    public String createAuthorizationCode(OAuth2Authentication authentication) {
        String code = UUID.randomUUID().toString();
        store(code, authentication);
        return code;
    }

}
